<!--宝生信审模板-->
<template>
  <div style="height:100%;overflow-y:auto">
    <Card>
      <Row>

          <Col span="2" style="text-align:center">
              <Button type="primary" @click="submitForm" maxlength="small">保  存</Button>
          </Col>
      </Row>
      </br>
      <Collapse v-model="value1">
        <Panel name="1">
          个人信息
          <div slot="content">
            <Form :label-width="80" :model="mcamBsCreditDataDTO" inline :rules="customerInfoFormRules" ref="customerInfoFormRef" >
              <FormItem label="姓名" prop="">
                <Input  v-model="mcamBsCreditDataDTO.custName" readonly ></Input>
              </FormItem>
              <FormItem label="证件号码" prop="">
                <Input  v-model="mcamBsCreditDataDTO.custIdCard" readonly ></Input>
              </FormItem>

              <FormItem label="性别" prop="">
                  <Select v-model="mcamBsCreditDataDTO.sex" class="task-process-detail-select" >
                      <Option v-for="item in selectSexData" :value="item.code" :key="item.code">{{ item.name }}</Option>
                  </Select>
              </FormItem>
              <FormItem label="年龄" prop="">
                <Input  v-model="mcamBsCreditDataDTO.age" readonly ></Input>
              </FormItem>
              </br>
              <FormItem label="民族" prop="">
                <Input  v-model="mcamBsCreditDataDTO.nationality" readonly ></Input>
              </FormItem>
              <FormItem label="户籍地址" prop="">
                <Input  v-model="mcamBsCreditDataDTO.cardAddress" readonly ></Input>
              </FormItem>
              <FormItem label="家庭地址" prop="">
                <Input  v-model="mcamBsCreditDataDTO.familyAddress" :maxlength="200" ></Input>
              </FormItem>
              <FormItem label="婚姻" prop="">
                <Select v-model="mcamBsCreditDataDTO.marriage" class="task-process-detail-select" >
                      <Option v-for="item in marriageData" :value="item.code" :key="item.code">{{ item.name }}</Option>
                  </Select>

              </FormItem>
              <br>
              <FormItem label="本地居住年限" prop="">
                <Input  v-model="mcamBsCreditDataDTO.liveTime" :maxlength="10" ></Input>
              </FormItem>
              <FormItem label="银行卡号" prop="">
                <Input  v-model="mcamBsCreditDataDTO.receiveAcct" readonly ></Input>
              </FormItem>
              <FormItem label="发卡行" prop="">
                <Input  v-model="mcamBsCreditDataDTO.receiveBankName" readonly></Input>
              </FormItem>
              <FormItem label="银行预留手机号码" prop="">
                <Input  v-model="mcamBsCreditDataDTO.mobileNum" readonly ></Input>
              </FormItem>
              <br>
              <FormItem label="申请经营贷" prop="">
                <Input  v-model="mcamBsCreditDataDTO.applyMoney" :maxlength="10" ></Input>
              </FormItem>
              <FormItem label="申请经营贷期限" prop="">
                <Input  v-model="mcamBsCreditDataDTO.applyMonth" :maxlength="3" ></Input>
              </FormItem>
            </Form>
          </div>
        </Panel>

         <Panel name="2">
          经营主体
          <div slot="content">
            <Form :label-width="120" inline>
              <FormItem label="企业主体名称" prop="">
                <Input  v-model="mcamBsCreditDataDTO.companyName" :maxlength="100" ></Input>
              </FormItem>
              <FormItem label="经工商信息查询注册时间" prop="">
                <Input  v-model="mcamBsCreditDataDTO.companyRegisterTime"  ></Input>
              </FormItem>
              <FormItem label="经营地址" prop="">
                <Input  v-model="mcamBsCreditDataDTO.companyAddress" :maxlength="200" ></Input>
              </FormItem>
              <FormItem label="经营状态" prop="">
                <Input   >正常</Input>
              </FormItem>
              </br>
                   是个体户或个人独资企业：
                   <RadioGroup v-model="mcamBsCreditDataDTO.partnerType">
                      <Radio label="负责人"><span>负责人</span></Radio>
                      <Radio label="合伙人"><span>合伙人</span></Radio>
                  </RadioGroup>
              </br></br>
                经核实确认，公司主营业务为
                <Input  v-model="mcamBsCreditDataDTO.businessScope" style="width:20%" :maxlength="50"></Input>
              </br></br>
                客户年营业额
                <Input  v-model="mcamBsCreditDataDTO.turnover" style="width:20%" :maxlength="10" ></Input>
              万元，利润率
                <Input  v-model="mcamBsCreditDataDTO.profitRate" style="width:20%" :maxlength="10"></Input>%。
                </br></br>
                经营场地为:
                <RadioGroup v-model="mcamBsCreditDataDTO.spaceType">
                      <Radio label="租赁"><span>租赁</span></Radio>
                      <Radio label="自有"><span>自有</span></Radio>
                  </RadioGroup>
            </Form>
          </div>
        </Panel>
        <Panel name="3">
          信用状况
          <div slot="content">
                  经查询人行、鹏元等征信报告，借款人无不良记录，非黑名单内人员。
                </br></br>
                  查询汇法网及工商信息等，借款人及企业无重大涉诉信息及未执行终结案件，企业不在黑名单内。
                </br></br>
                  对借款人提供的亲属及联系人，经验证，无异常，非黑名单人员。
                </br></br>
                  借款人及企业信用状况良好。
          </div>
        </Panel>
        <Panel name="4">
          资产输入
          <div slot="content">
            <Form :label-width="100"  :model="mcamBsCreditDataDTO" inline :rules="customerInfoFormRules" ref="customerInfoFormRef">
              <FormItem label="居住类型" prop="house">
                <Input  v-model="mcamBsCreditDataDTO.house" :maxlength="3" ></Input>
              </FormItem>
              <FormItem label="寿险保单（份）" prop="policy">
                <Input  v-model="mcamBsCreditDataDTO.policy" :maxlength="3" ></Input>
              </FormItem>
              <FormItem label="最长缴纳期限" prop="">
                <Input  v-model="mcamBsCreditDataDTO.maxPeriod" :maxlength="3" ></Input>
              </FormItem>
              <FormItem label="年缴保费" prop="yearPremium">
                <Input  v-model="mcamBsCreditDataDTO.yearPremium" :maxlength="10" ></Input>
              </FormItem>
              </br>
                  人行信用报告反映，个人住房按揭贷款（含个人住房公积金贷款）
               <Input  v-model="mcamBsCreditDataDTO.loanCount" style="width:10%" :maxlength="4"></Input>笔，月供
               <Input  v-model="mcamBsCreditDataDTO.monthlyPay" style="width:10%" :maxlength="10"></Input>元。
               </br></br>
                  综合借款人资产情况，核定月收入
               <Input  v-model="mcamBsCreditDataDTO.monthlyIncome" style="width:10%" :maxlength="10"></Input> 元。
            </Form>
          </div>
        </Panel>
        <Panel name="5">
          负债比
          <div slot="content">
              根据人行信用报告，借款人无担保贷款及信用卡月负债
              <Input  v-model="mcamBsCreditDataDTO.monthlyLiabilities" style="width:10%" :maxlength="10"></Input>元。
              核定收入负债比<Input  v-model="mcamBsCreditDataDTO.incomeLiabilityRatio" style="width:10%" :maxlength="10"></Input>。
          </div>
        </Panel>
        <Panel name="6">
          审查结论
          <div slot="content">
                综上，借款人具有较为稳定的住所和一定的资产实力，信用记录良好，经营企业正常，非国家限制性行业，无不良记录。
                </br></br>
                借款人总体负债比不高。
                </br></br>
                建议核定贷款金额<Input  v-model="mcamBsCreditDataDTO.approvedAmount" style="width:10%" :maxlength="10"></Input>万元，期限
                <Input  v-model="mcamBsCreditDataDTO.month" style="width:10%" :maxlength="3"></Input>月，还款方式：按月等额还本付息。
          </div>
        </Panel>
      </Collapse>
    </Card>
  </div>
</template>

<script>
export default {
  name: 'bs-credit-data',
  data () {
    const validateHouse = (rule, value, callback) => {
      var myreg = /^[0-9]*$/
      if (value == null || value === '' || !myreg.test(value)) {
        callback(new Error('请输入正确的房产笔数'))
      } else {
        callback()
      }
    }
    const validatePolicy = (rule, value, callback) => {
      var myreg = /^[0-9]*$/
      if (value == null || value === '' || !myreg.test(value)) {
        callback(new Error('请输入正确的寿险保单笔数'))
      } else {
        callback()
      }
    }
    const validateYearPremium = (rule, value, callback) => {
      var myreg = /^[0-9]+(.[0-9]{1,2})?$/
      if (value == null || value === '' || !myreg.test(value)) {
        callback(new Error('请输入正确的年缴保费'))
      } else {
        callback()
      }
    }
    return {
      value1: '1',
      customerInfoFormRules: {
        house: [{
          validator: validateHouse,
          trigger: 'blur'
        }],
        policy: [{
          validator: validatePolicy,
          trigger: 'blur'
        }],
        yearPremium: [{
          validator: validateYearPremium,
          trigger: 'blur'
        }]

      },
      mcamBsCreditDataDTO: { },
      selectSexData: [
        {
          code: '0',
          name: '女'
        },
        {
          code: '1',
          name: '男'
        }
      ],
      marriageData: [
        {
          code: '1',
          name: '未婚'
        },
        {
          code: '2',
          name: '已婚'
        },
        {
          code: '3',
          name: '离异'
        },
        {
          code: '4',
          name: '丧偶'
        },
        {
          code: '5',
          name: '其他'
        }
      ]

    }
  },
  methods: {
    initpage: function () {
      this.loadCredit()
    },
    // 信审数据
    loadCredit: function () {
      var vm = this
      var params = {}
      params.loanId = this.$route.query.loanId
      this.$ajax.get(this.$appContext.marvels_core_approve + '/approve/bsRepayPush/service/getBsCreditData', { params: params }).then(re => {
        var data = re.data
        var code = data.code
        var message = data.message
        if (code !== 'success') {
          this.$Message.warning(message)
          return
        }
        console.log(re.data.data)
        vm.mcamBsCreditDataDTO = re.data.data
        debugger
      }).catch(er => { })
    },
    submitForm () {
      if (!confirm('确认提交?')) {
        return
      }
      var vm = this
      var param = {
        mcamBsCreditDataDTO: vm.mcamBsCreditDataDTO
      }
      console.log(param)
      var validate = this.validSubmitData(param)
      if (validate) {
        this.$ajax.post(this.$appContext.marvels_core_approve + '/approve/bsRepayPush/service/submitFormBsCreditData', vm.mcamBsCreditDataDTO).then(re => {
          //     // if (re.data.code === 'success') {
          //     //   this.$Message.success(re.data.data)
          //     //   this.$router.push({ name: 'fundSource' })
          //     // } else {
          //     //   this.$Message.warning(re.data.data)
          //     // }
        })
          .catch(er => { })
      }
    },
    validSubmitData (param) {
      var flag = true
      var mcamBsCredit = param.mcamBsCreditDataDTO
      if (!mcamBsCredit.custName || mcamBsCredit.custName == null || mcamBsCredit.custName === '') {
        this.$Message.warning('姓名不能为空')
        flag = false
      }
      if (!mcamBsCredit.liveTime || mcamBsCredit.liveTime == null || mcamBsCredit.liveTime === '') {
        this.$Message.warning('本地居住年限不能为空')
        flag = false
      }
      if (!mcamBsCredit.custIdCard || mcamBsCredit.custIdCard == null || mcamBsCredit.custIdCard === '') {
        this.$Message.warning('证件号码不能为空')
        flag = false
      }
      if (!mcamBsCredit.familyAddress || mcamBsCredit.familyAddress == null || mcamBsCredit.familyAddress === '') {
        this.$Message.warning('家庭地址不能为空')
        flag = false
      }
      if (!mcamBsCredit.marriage || mcamBsCredit.marriage == null || mcamBsCredit.marriage === '') {
        this.$Message.warning('婚姻不能为空')
        flag = false
      }
      if (!mcamBsCredit.receiveAcct || mcamBsCredit.receiveAcct == null || mcamBsCredit.receiveAcct === '') {
        this.$Message.warning('银行卡号不能为空')
        flag = false
      }
      if (!mcamBsCredit.receiveBankName || mcamBsCredit.receiveBankName == null || mcamBsCredit.receiveBankName === '') {
        this.$Message.warning('发卡行不能为空')
        flag = false
      }
      if (!mcamBsCredit.mobileNum || mcamBsCredit.mobileNum == null || mcamBsCredit.mobileNum === '') {
        this.$Message.warning('银行预留手机号码不能为空')
        flag = false
      }
      if (!mcamBsCredit.applyMoney || mcamBsCredit.applyMoney == null || mcamBsCredit.applyMoney === '') {
        this.$Message.warning('申请经营贷不能为空')
        flag = false
      }
      if (!mcamBsCredit.applyMonth || mcamBsCredit.applyMonth == null || mcamBsCredit.applyMonth === '') {
        this.$Message.warning('申请经营贷期限不能为空')
        flag = false
      }
      if (!mcamBsCredit.companyName || mcamBsCredit.companyName == null || mcamBsCredit.companyName === '') {
        this.$Message.warning('企业主体名称不能为空')
        flag = false
      }
      if (!mcamBsCredit.companyRegisterTime || mcamBsCredit.companyRegisterTime == null || mcamBsCredit.companyRegisterTime === '') {
        this.$Message.warning('经工商信息查询注册时间不能为空')
        flag = false
      }
      if (!mcamBsCredit.companyAddress || mcamBsCredit.companyAddress == null || mcamBsCredit.companyAddress === '') {
        this.$Message.warning('经营地址不能为空')
        flag = false
      }
      if (!mcamBsCredit.businessScope || mcamBsCredit.businessScope == null || mcamBsCredit.businessScope === '') {
        this.$Message.warning('公司主营业务不能为空')
        flag = false
      }
      if (!mcamBsCredit.turnover || mcamBsCredit.turnover == null || mcamBsCredit.turnover === '') {
        this.$Message.warning('客户年营业额不能为空')
        flag = false
      }
      if (!mcamBsCredit.profitRate || mcamBsCredit.profitRate == null || mcamBsCredit.profitRate === '') {
        this.$Message.warning('利润率不能为空')
        flag = false
      }
      if (!mcamBsCredit.house || mcamBsCredit.house == null || mcamBsCredit.house === '') {
        this.$Message.warning('房产信息不能为空')
        flag = false
      }
      if (!mcamBsCredit.policy || mcamBsCredit.policy == null || mcamBsCredit.policy === '') {
        this.$Message.warning('寿险保单不能为空')
        flag = false
      }
      if (!mcamBsCredit.maxPeriod || mcamBsCredit.maxPeriod == null || mcamBsCredit.maxPeriod === '') {
        this.$Message.warning('最长缴纳期限不能为空')
        flag = false
      }
      if (!mcamBsCredit.yearPremium || mcamBsCredit.yearPremium == null || mcamBsCredit.yearPremium === '') {
        this.$Message.warning('年缴保费不能为空')
        flag = false
      }
      if (!mcamBsCredit.loanCount || mcamBsCredit.loanCount == null || mcamBsCredit.loanCount === '') {
        this.$Message.warning('个人住房按揭贷款笔数不能为空')
        flag = false
      }
      if (!mcamBsCredit.monthlyPay || mcamBsCredit.monthlyPay == null || mcamBsCredit.monthlyPay === '') {
        this.$Message.warning('月供不能为空')
        flag = false
      }
      if (!mcamBsCredit.monthlyIncome || mcamBsCredit.monthlyIncome == null || mcamBsCredit.monthlyIncome === '') {
        this.$Message.warning('核定月收入不能为空')
        flag = false
      }
      if (!mcamBsCredit.monthlyLiabilities || mcamBsCredit.monthlyLiabilities == null || mcamBsCredit.monthlyLiabilities === '') {
        this.$Message.warning('担保贷款及信用卡月负债不能为空')
        flag = false
      }
      if (!mcamBsCredit.incomeLiabilityRatio || mcamBsCredit.incomeLiabilityRatio == null || mcamBsCredit.incomeLiabilityRatio === '') {
        this.$Message.warning('核定收入负债比不能为空')
        flag = false
      }
      if (!mcamBsCredit.approvedAmount || mcamBsCredit.approvedAmount == null || mcamBsCredit.approvedAmount === '') {
        this.$Message.warning('核定贷款金额不能为空')
        flag = false
      }
      if (!mcamBsCredit.month || mcamBsCredit.month == null || mcamBsCredit.month === '') {
        this.$Message.warning('核定期限不能为空')
        flag = false
      }
      return flag
    }
  },
  created () {
    this.$ajax = this.$util.ajax()
  },

  watch: {
    // 点击tab页签，加载数据，只加载一次
    'taskParams.bsCreditDataForm' (v) {
      if (v) {
        this.loanId = this.taskParams.curLoanId
        this.initpage()
      }
    }
  },
  props: {
    taskParams: Object
  }
}

</script>
